<template>
	<view class="container" style="border: 2px solid red;background-color: #fff;">
		<view v-for="(item, index) in UserMenuPermissionsData" :key="index" style="border: 1px solid blue;">
			<view>{{ item.ModuleName}}</view>
			<treeNode :list="item.UMPTrees" @change="treeChange"></treeNode>
		</view>

	</view>
</template>

<script>
	// 引用树形结构组件
	import TreeNode from "@/components/treeNode.vue"
	// 引入公共接口文件
	import {
		// 个人权限列表
		Base_UserGetUserMenuPermissions
	} from "@/api/interface.js";
	import {
		mapState
	} from "vuex";
	export default {
		components: {
			TreeNode
		},
		data() {
			return {
				// 用户信息
				userInfo: {},
				// 个人权限列表
				UserMenuPermissionsData: [],
				list: [{
					id: '1',
					name: '机构一',
					children: [{
						id: '101',
						name: '人事部',
						children: []
					}, {
						id: '102',
						name: '总部',
						children: [{
							id: '1021',
							name: '选项一',
							children: []
						}, {
							id: '1022',
							name: '选项二',
							children: []
						}, {
							id: '1023',
							name: '选项三',
							children: []
						}]
					}, {
						id: '103',
						name: '后勤部',
						children: []
					}]
				}, {
					id: '12',
					name: '机构二',
					children: [{
						id: '10121',
						name: '选项一',
						children: []
					}, {
						id: '10122',
						name: '选项二',
						children: []
					}, {
						id: '10123',
						name: '选项三',
						children: []
					}]
				}, {
					id: '13',
					name: '机构三',
					children: [{
						id: '10131',
						name: '选项一',
						children: []
					}, {
						id: '10132',
						name: '选项二',
						children: []
					}, {
						id: '10133',
						name: '选项三',
						children: []
					}]
				}]
			}
		},
		onShow() {
			this.userInfo = this.UserInfo.UserInfo

			// 获取个人权限列表信息
			this.GetUserMenuPermissionsListData()
		},
		computed: {
			...mapState(["UserInfo"]),
		},
		methods: {
			// 树结节点点击事件
			treeChange(e) {
				uni.showToast({
					title: `选中的值：${e.name}`,
					icon: 'none'
				})
			},
			// 获取个人权限列表信息
			GetUserMenuPermissionsListData() {
				Base_UserGetUserMenuPermissions({
					userId: this.userInfo.Id
				}).then(resJson => {
					if (resJson.Success) {
						this.UserMenuPermissionsData = resJson.Data
					}
					console.log('获取权限用户j结果', this.UserMenuPermissionsData, resJson.Data)
				})

			}
		}
	}
</script>

<style scoped lang="less">
	.container {}
</style>